package com.freeunion.zhibo.utils;

import android.app.AlertDialog;
import android.content.Context;
import android.view.View;

import com.freeunion.zhibo.R;

public class UiUtils {
    /**
     * 创建一个"玩命加载中"的Dialog
     * @param context
     * @return
     */
    public static AlertDialog newLoadingDialog(Context context) {
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        View view = View.inflate(context, R.layout.view_loading, null);
        AlertDialog dialog = builder.create();
        dialog.setView(view, 0, 0, 0, 0);
        dialog.setCancelable(true);
        return dialog;
    }


    public static int dip2px(Context context, float dpValue) {
        final float scale = context.getResources().getDisplayMetrics().density;
        return (int) (dpValue * scale + 0.5f);
    }

}
